package com.charmzenus.message.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    KafkaTemplate kafkaTemplate;


    @ResponseBody
    @RequestMapping("/test")
    public String test() {

//        ListenableFuture send = kafkaTemplate.send("happy", "are you ok?");
//        send.addCallback(new ListenableFutureCallback() {
//
//            @Override
//            public void onFailure(Throwable throwable) {
//                System.out.println("onFailure");
//            }
//
//            @Override
//            public void onSuccess(Object o) {
//                System.out.println("onSuccess");
//            }
//        });

        return "hello";
    }




}
